package com.example.fontscalejava;

import android.content.Context;
import android.content.res.Configuration;

import androidx.appcompat.app.AppCompatActivity;

/**
 * 所有Activity的基类
 */
public class BaseActivity extends AppCompatActivity {

    @Override
    protected void attachBaseContext(Context newBase) {
        super.attachBaseContext(newBase);
        overrideFontScale(newBase);
    }

    /**
     * 重置配置 fontScale：保持字体比例不变，始终为 1.
     */
    private void overrideFontScale(Context context) {
        if (context == null) return;
        Configuration configuration = context.getResources().getConfiguration();
        configuration.fontScale = 1f;
        applyOverrideConfiguration(configuration);
    }

}